#include "nconvert.h"

char *formingName(char *, int, int);

void nconvert(char *directory)
{
    State state8(8), state12(12), state16(16);
    int size = state8.getSize();
    char *name;

    complexd h[] = {
        complexd(1/sqrt(2), 0), complexd( 1/sqrt(2), 0),
        complexd(1/sqrt(2), 0), complexd(-1/sqrt(2), 0)
    };
    Conversion H(2,2,h);

    state8.input("samples/state8");
    state12.input("samples/state12");
    state16.input("samples/state16");

    state8.n0Conversion(H);
    name = formingName(directory, 8, size);
    state8.output(name);

    state12.n0Conversion(H);
    name = formingName(directory, 12, size);
    state12.output(name);

    state16.n0Conversion(H);
    name = formingName(directory, 16, size);
    state16.output(name);
}

char *formingName(char *directory, int length, int size)
{
    char *name = new char [strlen(directory) + 20];
    sprintf(name, "%s/nstate_%d_%d", directory, length, size);
    return name;
}
